package com.xiaoxx.coin.po;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum BinanceOrderStatus {
    // 订单状态枚举
    NEW("NEW", "新建订单"),
    PARTIALLY_FILLED("PARTIALLY_FILLED", "部分成交"),
    FILLED("FILLED", "全部成交"),
    CANCELED("CANCELED", "已撤销"),
    REJECTED("REJECTED", "订单被拒绝"),
    EXPIRED("EXPIRED", "订单过期(根据timeInForce参数规则)"),
    EXPIRED_IN_MATCH("EXPIRED_IN_MATCH", "订单被STP过期");

    // 状态码
    private final String status;
    // 状态描述
    private final String description;

    // 根据状态码获取枚举
    public static BinanceOrderStatus ofStatus(String status) {
        for (BinanceOrderStatus orderStatus : BinanceOrderStatus.values()) {
            if (orderStatus.getStatus().equalsIgnoreCase(status)) {
                return orderStatus;
            }
        }
        throw new IllegalArgumentException("无效的订单状态: " + status);
    }
}
